<?php


namespace app\data\controller;
use app\data\model\DataUser;
use app\mall_back\model\TescoCommentModel;

use think\admin\Controller;

class Comment extends Controller{


    public function index()
    {
        $query = TescoCommentModel::mQuery()->order('id desc');
        $query->equal('tesco_record_id,lucky_draw_id')->dateBetween('create_time')->page();
    }

    // 当前列表数据处理
    protected function _index_page_filter(&$data){
       // die('_index_page_filter');
        foreach($data as &$vo){
           $user = DataUser::find($vo['u_id']);
           $vo['user_phone'] = $user['phone'];
           $vo['username'] = $user['username'];
           $vo['nickname'] = $user['nickname'];
        }
    }


    public function detail(){

        if (request()->isPost()){
            $param = request()->param();
            if(!$param['id']){$this->error('记录不存在！');}
            $model = TescoCommentModel::find($param['id']);
            if(empty($model)){$this->error('记录不存在！');}
            $model->recommend_type = intval($param['recommend_type']);
            $model->save();
        }

        TescoCommentModel::mForm('form');
    }

    /**
     * 表单数据处理
     * @param array $data
     */
    protected function _form_filter(array &$data){
        if(request()->isGET()){
            $data['images'] = explode('|',$data['images']);
            $data['user'] = DataUser::find($data['u_id']);
        }

    }


}
